implement igtut01;

include "sys.m";
    sys: Sys;

include "draw.m";
    draw: Draw;
    Point, Rect, Pointer, Image, Display, Font, Screen: import draw;

include "tk.m";
include "wmclient.m";
    wmclient: Wmclient;
    Window: import wmclient;
    
igtut01: module
{
    init: fn(ctxt: ref Draw->Context, args: list of string);
};

init(ctxt: ref Draw->Context, args: list of string)
{
    sys = load Sys Sys->PATH;
    draw = load Draw Draw->PATH;
    wmclient = load Wmclient Wmclient->PATH;
    
    wmclient->init();
    
    if (ctxt == nil)
        ctxt = wmclient->makedrawcontext();
        
    buts := wmclient->Resize | 
            wmclient->Hide | 
            wmclient->Help | 
            wmclient->OK;
            
    window := wmclient->window(ctxt, "Inferno Graphics Tutorial #1", buts);
    
    winsz: Rect;
    winsz.min.x = 0;
    winsz.min.y = 0;
    winsz.max.x = 320;
    winsz.max.y = 240;
    
    window.reshape(winsz);
    window.onscreen("place");
    
    display := window.display;
    image := window.image;
    
    red := display.color(Draw->Red);
    image.draw(image.r, red, nil, image.r.min);
    
    sys->sleep(5000);
    sys->print("Inferno Graphics Tutorial #1\n");
}